import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:panda/base/Constant.dart';
import 'package:panda/goods_by_cat_list/QiangGouChild.dart';
import 'package:panda/util/TrianglePainter.dart';

class QiangGouPage extends StatefulWidget {
  QiangGouPage({Key key}) : super(key: key);

  @override
  _QiangGouPageState createState() => _QiangGouPageState();
}

class _QiangGouPageState extends State<QiangGouPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;
  int current = 0;
  @override
  void initState() {
    super.initState();
    _tabController = new TabController(vsync: this, length:1);
    _tabController.addListener(() {
      current = _tabController.index;
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: Text('秒杀专区',
            style: TextStyle(
                fontSize: ScreenUtil.getInstance().setSp(BIG_FONT_SIZE),
                color: Colors.black)),
        backgroundColor: Colors.white,
        brightness: Brightness.light,
        centerTitle: true,
        iconTheme: new IconThemeData(color: Colors.black),
        elevation: 0.5,
      ),
      body: new Container(
        width: double.infinity,
        color: black,
        child: Column(
          children: <Widget>[
            new TabBar(
              labelPadding: EdgeInsets.all(0),
              indicatorColor: mainColor,
              indicatorWeight: 0.01,
              tabs: <Widget>[
                new Container(
                  height: 0,
                  width: double.infinity / 4,
                  decoration: BoxDecoration(
                    color: current == 0 ? mainColor : black,
                  ),
                  padding:
                      EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_15)),
                  child: Column(
                    children: <Widget>[
                      Text("08:00",
                          style: TextStyle(
                              fontSize: ScreenUtil.getInstance().setSp(
                                  current == 0
                                      ? BIG_FONT_SIZE
                                      : NORMAL_FONT_SIZE))),
                      Text("已结束",
                          style: TextStyle(
                              fontSize: ScreenUtil.getInstance()
                                  .setSp(MINI_FONT_SIZE))),
                    ],
                  ),
                ),
                // new Container(
                //   width: double.infinity / 4,
                //   decoration: BoxDecoration(
                //     color: current == 1 ? mainColor : black,
                //   ),
                //   padding:
                //       EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_15)),
                //   child: Column(
                //     children: <Widget>[
                //       Text("10:00",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance().setSp(
                //                   current == 1
                //                       ? BIG_FONT_SIZE
                //                       : NORMAL_FONT_SIZE))),
                //       Text("已结束",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance()
                //                   .setSp(MINI_FONT_SIZE))),
                //     ],
                //   ),
                // ),
                // new Container(
                //   width: double.infinity / 4,
                //   decoration: BoxDecoration(
                //     color: current == 2 ? mainColor : black,
                //   ),
                //   padding:
                //       EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_15)),
                //   child: Column(
                //     children: <Widget>[
                //       Text("14:00",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance().setSp(
                //                   current == 2
                //                       ? BIG_FONT_SIZE
                //                       : NORMAL_FONT_SIZE))),
                //       Text("已结束",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance()
                //                   .setSp(MINI_FONT_SIZE))),
                //     ],
                //   ),
                // ),
                // new Container(
                //   decoration: BoxDecoration(
                //     color: current == 3 ? mainColor : black,
                //   ),
                //   width: double.infinity / 4,
                //   padding:
                //       EdgeInsets.all(ScreenUtil.getInstance().setHeight(DP_15)),
                //   child: Column(
                //     children: <Widget>[
                //       Text("17:00",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance().setSp(
                //                   current == 3
                //                       ? BIG_FONT_SIZE
                //                       : NORMAL_FONT_SIZE))),
                //       Text("已结束",
                //           style: TextStyle(
                //               fontSize: ScreenUtil.getInstance()
                //                   .setSp(MINI_FONT_SIZE))),
                //     ],
                //   ),
                // ),
              ],
              controller: _tabController,
            ),
            // Container(
            //   decoration: BoxDecoration(
            //     border: Border.all(color: white,width: 0),
            //     color: white
            //   ),
            //   child: Row(
            //     children: <Widget>[
            //       Expanded(
            //         child: Center(
            //           child: CustomPaint(
            //               painter: TrianglePainter(current==0?mainColor:white),
            //               size: Size(15, 15)),
            //         ),
            //       ),
            //       Expanded(
            //         child: Center(
            //           child: CustomPaint(
            //               painter: TrianglePainter(current==1?mainColor:white),
            //               size: Size(15, 15)),
            //         ),
            //       ),
            //       Expanded(
            //         child: Center(
            //           child: CustomPaint(
            //               painter: TrianglePainter(current==2?mainColor:white),
            //               size: Size(15, 15)),
            //         ),
            //       ),
            //       Expanded(
            //         child: Center(
            //           child: CustomPaint(
            //               painter: TrianglePainter(current==3?mainColor:white),
            //               size: Size(15, 15)),
            //         ),
            //       ),
            //     ],
            //   ),
            // ),
            Expanded(
              child: Container(
                color: white,
                child: new TabBarView(
                  controller: _tabController,
                  children: <Widget>[
                    new QiangGouChildPage(time:"08:00"),
                    // new QiangGouChildPage(time:"10:00"),
                    // new QiangGouChildPage(time:"14:00"),
                    // new QiangGouChildPage(time:"17:00"),
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
